package www.openteam.com.presenter.prdctnMngmnt;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.MaxRdsno;
import www.openteam.com.bean.StockTaxLocation;
import www.openteam.com.bean.StockTaxMaterial;
import www.openteam.com.bean.UpdateInfo;
import www.openteam.com.contract.PrdctnMngmnt.StockTaxContract;
import www.openteam.com.contract.realtime.StockContract;
import www.openteam.com.model.PrdctnMngmnt.StockTaxModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.prdctnMngmnt.Stock_TakFragment;

/**
 * Created by Administrator on 2019-12-24.
 */

public class StockTaxPrst extends BasePresenter<Stock_TakFragment>
        implements StockTaxContract.StockTaxPresenter {



    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new StockTaxModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("StockTaxModel", models[0]);
        return hashMap;
    }

    @Override
    public void findDataFromClassCode(String code,String lcode) {
        ((StockTaxModel) getiModelMap().get("StockTaxModel")).getDataFromClassCode(code,lcode, new StockTaxModel.DataFromClassCodeListener() {
            @Override
            public void success(StockTaxMaterial stockTaxMaterial) {
                getIView().findDataFromClassCode(stockTaxMaterial);
            }

            @Override
            public void fail(String msg) {
                getIView().findDataFromClassCodeFail(msg);
            }
        });
    }

    @Override
    public void findLocation() {
        ((StockTaxModel) getiModelMap().get("StockTaxModel")).findLocation(new StockTaxModel.LocationListener() {
            @Override
            public void success(StockTaxLocation stockTaxLocation) {
                getIView().findLocation(stockTaxLocation);
            }

            @Override
            public void fail(String msg) {
                getIView().findLocationFail(msg);
            }
        });
    }

    @Override
    public void findMaxRdsno(String tablename, String morecom, String prefix, String link, String year, String month) {
        ((StockTaxModel) getiModelMap().get("StockTaxModel")).findMaxRdsno(tablename, morecom, prefix, link, year, month,
                new StockTaxModel.MaxRdsnoListener() {
            @Override
            public void success(MaxRdsno maxRdsno) {
                getIView().findMaxRdsno(maxRdsno);
            }

            @Override
            public void fail(String msg) {
                getIView().findMaxRdsnoFail(msg);
            }
        });
    }

    @Override
    public void insertStCheckStock(String group, String inputer, final String morecom,String mid,String inputDate) {
        ((StockTaxModel) getiModelMap().get("StockTaxModel")).insertStCheck(group, inputer, morecom,mid,inputDate,
                new StockTaxModel.InsertStCheckListener() {
            @Override
            public void success(UpdateInfo info) {
                getIView().insertStCkStkSucess(info);
            }

            @Override
            public void fail(String msg) {
                getIView().insertStCkStkFail(msg);
            }
        });
    }
}
